#pragma once

#include <windows.h>

class PMFile
{
public:
	enum OperationMode
	{
		MRead=GENERIC_READ,
		MWrite=GENERIC_WRITE
	};
	enum AttribFlag
	{
		ModeHide=FILE_ATTRIBUTE_HIDDEN
	};
	enum MoveMethod
	{
		MovBegin=FILE_BEGIN,
		MovCurr=FILE_CURRENT,
		MoveEnd=FILE_END
	};
	PMFile(void);
	~PMFile(void);
	DWORD OpenWrite(LPCTSTR,DWORD=0);
	DWORD OpenRead(LPCTSTR,DWORD=0);
	DWORD Close(void);
	DWORD Write(LPVOID,DWORD);
	DWORD Read(LPVOID buf,DWORD bufsize);
	DWORD FileSize()
	{
		return GetFileSize( m_Handle,NULL);
	}
	DWORD ReadLine(LPVOID buf,DWORD bufsize,LPDWORD);
	DWORD GetCurrentPointer();
	DWORD SetPointer(LONG offset,DWORD method=MovBegin);
private:
	HANDLE m_Handle;
	DWORD CheckBlank(LPBYTE buf,DWORD bufsize,LPDWORD plen);
};
